﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;


namespace XNAViewerSample.Forms
{
    public class ListConverter : StringConverter
    {
        private static List<String> mList = new List<String>();
        private static List<String> sList = new List<String>();
        private static List<String> aList = new List<String>();
        private static List<String> tList = new List<String>();
        private static List<String> bList = new List<String>();
        private static List<String> fList = new List<String>();
        private static List<String> dList = new List<String>();
        private static List<String> eList = new List<String>();
        private static List<String> vList = new List<String>();

        public static void SetList(String listName, List<String> l)
        {
            if (listName == "ID")
                mList = l;
            if (listName == SelectedModel.ctype.Tops.ToString())
                tList = l;
            if (listName == SelectedModel.ctype.Bottom.ToString())
                bList = l;
            if (listName == SelectedModel.ctype.Skirt.ToString())
                sList = l;
            if (listName == SelectedModel.atype.Feet.ToString())
                fList = l;
            if (listName == "Animation")
                aList = l;
            if (listName == "Dance")
                dList = l;
            if (listName == "Expression")
                eList = l;
            if (listName == "Viseme")
                vList = l;
        }

        public override bool GetStandardValuesSupported(
                           ITypeDescriptorContext context)
        {
            return true;
        }
        public override bool GetStandardValuesExclusive(
                           ITypeDescriptorContext context)
        {
            return true;
        }

        public override StandardValuesCollection
                             GetStandardValues(ITypeDescriptorContext context)
        {
            if (context.PropertyDescriptor.Name == "ID")
                return new StandardValuesCollection(mList.ToArray<String>());
            if (context.PropertyDescriptor.Name == SelectedModel.ctype.Tops.ToString())
                return new StandardValuesCollection(tList.ToArray<String>());
            if (context.PropertyDescriptor.Name == SelectedModel.ctype.Bottom.ToString())
                return new StandardValuesCollection(bList.ToArray<String>());
            if (context.PropertyDescriptor.Name == SelectedModel.ctype.Skirt.ToString())
                return new StandardValuesCollection(sList.ToArray<String>());
            if (context.PropertyDescriptor.Name == SelectedModel.atype.Feet.ToString())
                return new StandardValuesCollection(fList.ToArray<String>());
            if (context.PropertyDescriptor.Name == "Animation")
                return new StandardValuesCollection(aList.ToArray<String>());
            if (context.PropertyDescriptor.Name == "Dance")
                return new StandardValuesCollection(dList.ToArray<String>());
            if (context.PropertyDescriptor.Name == "Expression")
                return new StandardValuesCollection(eList.ToArray<String>());
            if (context.PropertyDescriptor.Name == "Visemes")
                return new StandardValuesCollection(vList.ToArray<String>());
            return null;
        }
    }
    [DefaultPropertyAttribute("ID")]
    public class SelectedModel
    {
        private String id;
        public enum mtype { Normal, OnePiece, BodyFit, Bikini, Nude }; 
        public enum htype { Normal, Advanced };
        public enum ctype { Tops, Bottom, Feet, Skirt };
        public enum atype { Feet };
        private mtype modelType = mtype.Normal;
        private htype hairType = htype.Normal;
        private Boolean allowMixed;
        private String tops;
        private String bottom;
        private String feet;
        private String skirt;
        private String animation;
        private String dance;
        private String expression;
        private String visemes;

        [TypeConverter(typeof(ListConverter)),
         DescriptionAttribute("The ID of currently selected model."),
         CategoryAttribute("0: Model Information")]
        public String ID
        {
            get { return id; }
            set { id = value; }
        }
        [CategoryAttribute("1: Settings"),
         DefaultValueAttribute(mtype.Normal)]
        public mtype ClothingType
        {
            get { return modelType; }
            set { modelType = value; }
        }
        [CategoryAttribute("1: Settings"),
         DefaultValueAttribute(htype.Normal)]
        public htype HairType
        {
            get { return hairType; }
            set { hairType = value; }
        }
        [CategoryAttribute("2: Clothing"),
         DescriptionAttribute("Caution: When mixing types, clothing may appear incorrectly if texture and mesh do not correspond."),
         DefaultValueAttribute(false)]
        public Boolean AllowMixed
        {
            get { return allowMixed; }
            set { allowMixed = value; }
        }
        [CategoryAttribute("2: Clothing"),
         TypeConverter(typeof(ListConverter)),
         DefaultValueAttribute("")]
        public String Tops
        {
            get { return tops; }
            set { tops = value; }
        }
        [CategoryAttribute("2: Clothing"),
         TypeConverter(typeof(ListConverter)),
         DefaultValueAttribute("")]
        public String Bottom
        {
            get { return bottom; }
            set { bottom = value; }
        }
        [CategoryAttribute("2: Clothing"),
         TypeConverter(typeof(ListConverter)),
         DefaultValueAttribute("")]
        public String Skirt
        {
            get { return skirt; }
            set { skirt = value; }
        }
        [CategoryAttribute("2: Clothing"),
         TypeConverter(typeof(ListConverter)),
         DefaultValueAttribute("")]
        public String Feet
        {
            get { return feet; }
            set { feet = value; }
        }

        [TypeConverter(typeof(ListConverter)), 
         CategoryAttribute("3: Imports"),
         DefaultValueAttribute("")]
        public String Animation
        {
            get { return animation; }
            set { animation = value; }
        }

        [TypeConverter(typeof(ListConverter)),
         DescriptionAttribute("Lists dance steps randomly chosen when audio file is dropped on game window. Not selectable."),
         CategoryAttribute("3: Imports"),
         DefaultValueAttribute("List of moves")]
        public String Dance
        {
            get { return dance; }
            set { dance = value; }
        }

        [TypeConverter(typeof(ListConverter)),
         CategoryAttribute("3: Imports"),
         DefaultValueAttribute("Base")]
        public String Expression
        {
            get { return expression; }
            set { expression = value; }
        }

        [TypeConverter(typeof(ListConverter)),
         DescriptionAttribute("Lists character visemes. Not selectable."),
         CategoryAttribute("3: Imports"),
         DefaultValueAttribute("List of visemes")]
        public String Visemes
        {
            get { return visemes; }
            set { visemes = value; }
        }

    }
}
